<?php

namespace app\index\model;

use think\Model;

class PhotoColl extends Model
{
    protected $name = 'car_photo_coll';
    protected $autoWriteTimestamp = true;
    protected $dateFormat = 'Y/m/d H:i:s';
    protected $createTime = 'create_at';
    protected $updateTime = 'update_at';

    public function info() {
        return $this->hasOne(PhotoList::class, 'id', 'photo_id')->withCount(['like', 'coll', 'buy']);
    }
    public function cover() {
        return $this->hasOne(PhotoList::class, 'id', 'photo_id')->bind([
            'new_cover' => 'cover'
        ]);
    }

    public function buy()
    {
        return $this->hasOne(PhotoBuy::class, 'photo_id', 'photo_id');
    }
}